#!/usr/bin/ruby

require 'test/unit'
require 'lib/rire'
require 'parsedate'

class TestRss < Test::Unit::TestCase
  def setup
    @dsl = Rire::DSL.new($rire_home + '/plugin')
    @dsl.instance_eval <<-EOD
      def execute(src)
        instance_eval(src, 'unit.dsl', 1)
      end
    EOD
  end

  def test_no_arg
    src = <<-"SCENARIO"
      define_task do
        subscribe.rss :config => {
          :link => "#{$rire_home}/test/subscribe/config_rss20.xml",
		}

        publish.rss :config => {
          :foo => "#{$rire_home}/test/publish/config_rss20.xml",
		}
      end
    SCENARIO

    ctx = @dsl.execute(src)

    assert(!File.exist?("#{$rire_home}/test/publish/config_rss20.xml"))
  end

  def test_feed
    src = <<-"SCENARIO"
      define_task do
        subscribe.rss :config => {
          :link => "#{$rire_home}/test/subscribe/config_rss20.xml",
		}

        publish.rss :config => {
          :filename => "#{$rire_home}/test/publish/config_rss20.xml",
		}
      end
    SCENARIO

    ctx = @dsl.execute(src)

    assert(File.exist?("#{$rire_home}/test/publish/config_rss20.xml"))

    File.unlink("#{$rire_home}/test/publish/config_rss20.xml")
  end

  def teardown
  end
end

